home *** CD-ROM | disk | FTP | other *** search
- unit Dragdrpu;
-
- interface
-
- uses
- SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
- Forms, Dialogs, StdCtrls, ExtCtrls, Grids, FileCtrl, DBGrids, DB,
- DBTables;
-
- type
- TForm1 = class(TForm)
- StringGrid1: TStringGrid;
- SourceControl: TFileListBox;
- DirectoryListBox1: TDirectoryListBox;
- DriveComboBox1: TDriveComboBox;
- DataSource1: TDataSource;
- Table1: TTable;
- DBGrid1: TDBGrid;
- procedure GridDragOver(Sender, Source: TObject; X, Y: Integer;
- State: TDragState; var Accept: Boolean);
- procedure StringGridDragDrop(Sender, Source: TObject; X, Y: Integer);
- procedure DBGridDragDrop(Sender, Source: TObject; X, Y: Integer);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
-
- var
- Form1: TForm1;
-
- implementation
-
- {$R *.DFM}
-
- procedure TForm1.GridDragOver(Sender, Source: TObject; X,
- Y: Integer; State: TDragState; var Accept: Boolean);
- begin
- Accept := Source = SourceControl;
- end;
-
- procedure TForm1.StringGridDragDrop(Sender, Source: TObject; X,
- Y: Integer);
- begin
- if Source <> SourceControl then Exit;
- with Sender as TStringGrid do
- begin
- Perform(wm_LButtonDown, 0, MakeLong(X, Y));
- Perform(wm_LButtonUp, 0, MakeLong(X, Y));
- Cells[Selection.Left, Selection.Top] := SourceControl.FileName;
- end;
- end;
-
- procedure TForm1.DBGridDragDrop(Sender, Source: TObject; X, Y: Integer);
- begin
- if Source <> SourceControl then Exit;
- with Sender as TDBGrid do
- begin
- Perform(wm_LButtonDown, 0, MakeLong(X, Y));
- Perform(wm_LButtonUp, 0, MakeLong(X, Y));
- SelectedField.DataSet.Edit;
- SelectedField.AsString := SourceControl.FileName;
- end;
- end;
-
- end.
-